package com.ruoyi.web.controller.system;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.BEFileOld;
import com.ruoyi.system.service.IBEFileOldService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 电子旧文件Controller
 * 
 * @author ruoyi
 * @date 2023-09-22
 */
@RestController
@RequestMapping("/system/oldefile")
public class BEFileOldController extends BaseController
{
    @Autowired
    private IBEFileOldService bEFileOldService;

    /**
     * 查询电子旧文件列表
     */
    //@PreAuthorize("@ss.hasPermi('system:oldefile:list')")
    @GetMapping("/list")
    public TableDataInfo list(BEFileOld bEFileOld)
    {
        startPage();
        List<BEFileOld> list = bEFileOldService.selectBEFileOldList(bEFileOld);
        return getDataTable(list);
    }

    /**
     * 导出电子旧文件列表
     */
    //@PreAuthorize("@ss.hasPermi('system:oldefile:export')")
    @Log(title = "电子旧文件", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BEFileOld bEFileOld)
    {
        List<BEFileOld> list = bEFileOldService.selectBEFileOldList(bEFileOld);
        ExcelUtil<BEFileOld> util = new ExcelUtil<BEFileOld>(BEFileOld.class);
        util.exportExcel(response, list, "电子旧文件数据");
    }

    /**
     * 获取电子旧文件详细信息
     */
    //@PreAuthorize("@ss.hasPermi('system:oldefile:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bEFileOldService.selectBEFileOldById(id));
    }

    /**
     * 新增电子旧文件
     */
    //@PreAuthorize("@ss.hasPermi('system:oldefile:add')")
    @Log(title = "电子旧文件", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BEFileOld bEFileOld)
    {
        return toAjax(bEFileOldService.insertBEFileOld(bEFileOld));
    }

    /**
     * 修改电子旧文件
     */
    //@PreAuthorize("@ss.hasPermi('system:oldefile:edit')")
    @Log(title = "电子旧文件", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BEFileOld bEFileOld)
    {
        return toAjax(bEFileOldService.updateBEFileOld(bEFileOld));
    }

    /**
     * 删除电子旧文件
     */
    //@PreAuthorize("@ss.hasPermi('system:oldefile:remove')")
    @Log(title = "电子旧文件", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bEFileOldService.deleteBEFileOldByIds(ids));
    }
}
